<!-- 弹窗分页选择大集合 -->
<template>
  <div class="selectTableMeet">
    <ele-dialog-table
      :title="$i18n.t('pickingList.modelDialogTitleMater')"
      width="70%"
      :visible.sync="codeDislogVisible"
      :formConfig="searchConfig"
      :column="column"
      @getSelectData="getSelectCode"
      :getList="api"
      :key="time"
    >
    </ele-dialog-table>
  </div>
</template>

<script>
//例如：import 《组件名称》 from '《组件路径》';

import {
  getList as getList2,
  getGoodsTypeKeyList,
  getManufactureMethodValueList,
  getSeriesCodeList,
} from "@/api/data/baseGoods";

export default {
  name: "",
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      time: "0",
      type: 1, //  1模板选择
      api: null,
      codeDislogVisible: false,
      searchConfig: {},
      column: [],
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    show(type) {
      this.api = getList2;
      this.type = 2;
      // 初始化table数据
      this.getInitData(type);
      this.time = new Date().getTime();
      this.codeDislogVisible = true;
    },
    getSelectCode(data) {
      // let obj = {
      //   type: this.type,
      //   data: data.length ? data[0] : {},
      // };
      this.$emit("getSelectCode", data);
    },

    getInitData(type) {
      this.column = [
        {
          type: "selection",
        },
        {
          type: "index",
          label: $i18n.t("common.order"),
          width: 60,
          fixed: "left",
        },
        {
          prop: "goodsCode",
          label: $i18n.t("pickingList.goodsCode"),
          width: "160",
          showOverflowTooltip: true,
        },
        {
          prop: "goodsName",
          label: $i18n.t("pickingList.goodsName"),
          width: "200",
          showOverflowTooltip: true,
        },
        {
          prop: "seriesCode",
          label: $i18n.t("pickingList.seriesCode"),
          width: "160",
          optionProp: {
            value: "seriesCode",
            label: "seriesName",
          },
          option: async (data) => {
            const list = await getSeriesCodeList();
            self.seriesCodeList = list.data.result;
            return list.data.result;
          },
        },
        {
          prop: "goodsTypeKey",
          label: $i18n.t("pickingList.goodsTypeKey"),
          width: "140",
          optionProp: {
            value: "value",
            label: "description",
          },
          option: async (data) => {
            const list = await getGoodsTypeKeyList();
            self.goodsTypeList = list.data.result;
            return list.data.result;
          },
        },
        {
          prop: "manufactureMethodValue",
          label: $i18n.t("pickingList.manufactureMethodValue"),
          width: "170",
          optionProp: {
            value: "value",
            label: "description",
          },
          option: async (data) => {
            const list = await getManufactureMethodValueList();
            self.manufactureMethodList = list.data.result;
            return list.data.result;
          },
        },
      ];
      this.searchConfig = {
        inline: true,
        formDesc: {
          goodsCode: {
            type: "input",
            label: $i18n.t("pickingList.goodsCode"),
          },
          goodsName: {
            type: "input",
            label: $i18n.t("pickingList.goodsName"),
          },
          goodsTypeKey: {
            type: "select",
            label: $i18n.t("pickingList.goodsTypeKey"),
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getGoodsTypeKeyList();
              return list.data.result;
            },
          },
        },
      };
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
};
</script>
<style scoped lang="scss"></style>
